/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.ipccenter.resource;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Dictionary;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;

/**
 *
 * @author Mari
 */
public class MyDictionary {
    private Set<String> dictionary = new HashSet<String>();

    public Set<String> getDictionary() {
        return dictionary;
    }

    public void setDictionary(Set<String> dictionary) {
        this.dictionary = dictionary;
    }
    public void fillDictionary() {
        try {
            Scanner filescan = new Scanner(new File("dictionary.txt"));
            while (filescan.hasNext()) {
            dictionary.add(filescan.nextLine().toLowerCase());
            }
        }
        
        catch (FileNotFoundException e) {
            return;
        }
    }
    
    
    
    public static void main(String[] args){
       MyDictionary d = new MyDictionary();
       DamerauLevensteinMetric m = new DamerauLevensteinMetric();
       
       d.fillDictionary();
       Iterator i = d.getDictionary().iterator();
       while(i.hasNext()){
           String tmp = (String) i.next();
            System.out.println(m.getDistance("apple",tmp, 2)+tmp);
       }
   }
}
